package com.px.service;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.util.List;


public interface MongoService<T> {
    //保存数据
    void save(T t) throws Exception;
    //根据条件查询集合对象
    <T> List<T> find(Class<T> clazz, Query query) throws Exception ;
    //查询一条记录
    <T> T findOne(Class<T> clazz, Query query) throws Exception ;
    //根据ID查询一个对象
    <T> T findById(Class<T> clazz, Object id) throws Exception ;
    //根据条件查询总条数
    <T> long findCount(Class<T> clazz, Query query) throws Exception ;
    //根据属性查询对象
    <T> T findByLong(String name, Long value, Class<T> clazz)  throws Exception ;
    //分页查询
    List<T> pagination(Class<T> clazz, int pageSize, int pageNum, Query query);
    //删除集合
    <T> void dropCollection(Class<T> entityClass);
    //删除对象
    void deleteByLong(String key, Long value, Class<T> clazz) throws Exception ;
    //删除对象
    void deleteByString(String key, String value, Class<T> clazz) throws Exception ;
    //删除对象
    int delete(T t);
    //更新一条记录
    <T> Long updateFirst(Class<T> clazz, Query query, Update updat);
}
